import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;

import java.util.concurrent.TimeoutException;

public class Send {
    private final static String QUEUE_NAME = "hello-test";

    public static void main(String[] argv)
            throws java.io.IOException, TimeoutException, InterruptedException {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("10.10.11.243");
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(QUEUE_NAME, false, false, false, null);
        String message = " Hello World! ";
        for (int i = 0; i < 100; i++) {
            channel.basicPublish("", QUEUE_NAME, null, (i+message).getBytes());
            System.out.println(" [x] Sent '" + i+message + "'");
            Thread.sleep(2000);
        }

        channel.close();
        connection.close();
    }
}
